package com.miyake.dsp.converter.ui;

import com.miyake.dsp.converter.LogSetting;
import com.miyake.dsp.ui.DspTextField;
import com.miyake.dsp.ui.DspWidget;

public class LogSettingUI extends DspWidget {

	private LogSetting setting;

	public LogSettingUI(LogSetting setting) {
		this.setName("Log Setting");
		this.setting = setting;
		createMagnitude();
		createBottom();
	}

	private void createMagnitude() {
		DspTextField text = new DspTextField("Magnitude");
		text.setValue(String.valueOf(setting.getMagnitude()));
		this.add(text);
		
		text.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				setting.setMagnitude(Double.valueOf(value));
				fireChange(value);
			}
		});	
	}
	
	private void createBottom() {
		DspTextField text = new DspTextField("Bottom");
		text.setValue(String.valueOf(setting.getBottom()));
		this.add(text);
		
		text.addHandler(new DspWidgetHandler() {
			@Override
			public void onChange(String value) {
				setting.setBottom(Double.valueOf(value));
				fireChange(value);
			}
		});	
	}
}
